package UIComponents
{
	import flash.display.DisplayObject;
	import flash.display.DisplayObjectContainer;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.net.URLRequest;
	import flash.net.navigateToURL;
	import flash.text.TextField;
	
	/** 
	 * @author thy
	 * @version 1.0.0 
	 * 创建时间：Apr 24, 2012 4:34:43 PM 
	 */ 
	public class QQVipTQ extends Sprite
	{
//		private var lqBtn:DisplayObject;
		private var closeBtn:DisplayObject;
		
		private var xhnz:DisplayObject;
		private var fhfnBtn:DisplayObjectContainer;
		private var hzfn:DisplayObjectContainer;
		
		public function QQVipTQ()
		{
			init();
		}
		
		private function init():void
		{
			closeBtn=this.getChildByName("closeBtn");
//			this.lqBtn=this.getChildByName("lqBtn");
			xhnz=this.getChildByName("xhnz");
			fhfnBtn=this.getChildByName("fhfnBtn") as DisplayObjectContainer;
			hzfn=this.getChildByName("hzfn") as DisplayObjectContainer;
			
//			this.lqBtn.addEventListener(MouseEvent.CLICK,lqFun);
			this.closeBtn.addEventListener(MouseEvent.CLICK,onClick);
			xhnz.addEventListener(MouseEvent.CLICK,qqnhz);
//			fhfnBtn.addEventListener(MouseEvent.CLICK,qqhz);
			fhfnBtn.getChildByName("khz").addEventListener(MouseEvent.CLICK,qqhz);
			fhfnBtn.getChildByName("knhz").addEventListener(MouseEvent.CLICK,qqnhz);
//			hzfn.addEventListener(MouseEvent.CLICK,qqhz);
			hzfn.getChildByName("xfhz").addEventListener(MouseEvent.CLICK,qqhz);
			hzfn.getChildByName("ktnhz").addEventListener(MouseEvent.CLICK,qqhz);
		}
		
		private function onClick(e:MouseEvent):void
		{
			this.dispatchEvent(new PanelEvent(PanelEvent.CLOSE,true));
		}
		
//		private function lqFun(e:MouseEvent):void
//		{
//			this.dispatchEvent(new PanelEvent(PanelEvent.CUSTOMCALLBACK,true));
//		}
		
		private function qqhz(e:Event):void
		{
			navigateToURL(new URLRequest(FlatInfo.vipLink));
		}
		
		private function qqnhz(e:Event):void
		{
			navigateToURL(new URLRequest(FlatInfo.qqYearVipLink));
		}
		
		public function setTqData(lv:int,dayQQGiftObj:Object,yearObj:Object):void
		{
			if(lv==0)
			{
				this.fhfnBtn.visible=true;
				this.xhnz.visible=false;
				this.hzfn.visible=false;
			}else if(lv>0 && lv<101)
			{
				this.fhfnBtn.visible=false;
				this.xhnz.visible=false;
				this.hzfn.visible=true;
			}else if(lv>100){
				this.fhfnBtn.visible=false;
				this.xhnz.visible=true;
				this.hzfn.visible=false;
			}
			
			for(var i:int=1;i<9;i++)
			{
				var arr:Array=dayQQGiftObj[i];
				var sp:DisplayObjectContainer=this.getChildByName("qqicon"+i) as DisplayObjectContainer;
				
				for(var j:int=0;j<arr.length;j++)
				{
					var obj:Object=arr[j];
					var dis:DisplayObject=null;
					var des:String="";
					if(obj)
					{
						dis=obj.icon;
						dis.width=30;
						dis.height=30;
						des=dis["displayViewIconName"];
					}
					(sp.getChildByName("item"+(j+1)) as IconContainer).addPic(dis,des);
					(sp.getChildByName("itemNum"+(j+1)) as TextField).text="X"+obj.itemNum;
					(sp.getChildByName("itemNum"+(j+1)) as TextField).mouseEnabled=false;
					(sp.getChildByName("itemNum"+(j+1)) as TextField).selectable=false;
				}
//				(sp.getChildByName("item1") as IconContainer).addPic();
//				(sp.getChildByName("item2") as IconContainer).addPic();
//				(sp.getChildByName("itemNum1") as TextField).text="";
//				(sp.getChildByName("itemNum2") as TextField).text="";
				
				(this.getChildByName("nNun") as TextField).text="X"+yearObj.itemNum;
				(this.getChildByName("nicon") as IconContainer).addPic(yearObj.icon,yearObj.icon["displayViewIconName"]);
				(this.getChildByName("nNun") as TextField).mouseEnabled=false;
				(this.getChildByName("nNun") as TextField).selectable=false;
			}
			
		}
		
	}
}
